/**
 * Created by x on 14-3-24.
 */
function picker_element(options) {
    return   function(value, obj) {
        var v = {id: '', text: ''};
        if (value) {
            v.id = $(value).attr('id');
            v.text = $(value).text();
        }
        var s = "<div id='" + obj.id + "'  data-picker-url='" + options.url +  "'  data-picker-title='" + options.title + "'>";
        s += "<input type='hidden' class='input-value' value='" + v.id + "'/>";
        s += "<input type='text' class='input-text pickerBtn' value='" + v.text + "'/>";
        s += "</div>";
        var el = $(s);
        return el;
    }
}

function picker_value(options) {
    return function(el, oper, value) {
        var id = $(".input-value", el[0]).val();
        var text = $(".input-text", el[0]).val();
        return { id: id, text: text };
    }
}

function picker_formatter(opt) {
    return function(cellvalue, options, rowObject) {
        var s = "<span id=''></span>"
        if (cellvalue && cellvalue.id && cellvalue.text) {
            s = "<span id='" + cellvalue.id + "'>" + cellvalue.text + "</span>";
            return s;
        }
        return s;
    }
}

function picker_unformatter(opt) {
    return function(cellvalue, options, cell) {
        var value = {id: '', text: ''};
        if (cellvalue) {
            value.id = $(cellvalue).attr('id');
            value.text = $(cellvalue).text();
        }
        return  value;
    }
}